package com.hdax.dm.item.controller;

import com.hdax.dm.common.exception.DmException;
import com.hdax.dm.item.service.ItemCommentService;
import com.hdax.dm.item.vo.ItemCommentVo;
import com.hdax.dm.utils.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/item")
public class ItemCommentController {

    @Autowired
    private ItemCommentService itemCommentService;
    @RequestMapping("/desc/getComments")
    public CommonResponse getComments(@RequestBody Map<String,Long> param){
        return itemCommentService.getComments(param.get("id"));
    }

    @RequestMapping("/p/desc/addComments")
    public CommonResponse addComments(@RequestBody ItemCommentVo itemCommentVo, HttpServletRequest request) throws DmException {
        return itemCommentService.addComments(itemCommentVo,request.getHeader("token"));
    }



}
